import React, { useRef, useEffect, memo, useState } from 'react';
import { Row, Col, Input, Button, Table } from 'antd';
import styles from './index.less';
import useModel from '../../useModel.js';
import classnames from 'classnames';
import Connect from '@/components/Connect';
import { useAntdTable } from '@umijs/hooks';

const DictionnaryTable = () => {
  const { run } = useModel(model => [model.run]);
  let row = localStorage.getItem('deviceType');
  const { tableProps } = useAntdTable(
    ({ current, pageSize, gender }) =>
      run({ currentPage: current, pageSize: pageSize, fsuTypeId: row && JSON.parse(row)?.id }).then(
        res => ({
          total: res?.data?.totalCount || 0,
          data: res?.data?.dataList || [],
        }),
      ),
    {
      defaultPageSize: 10,
    },
  );

  const columns = [
    {
      title: '设备类型名称',
      align: 'center',
      dataIndex: 'deviceTypeName',
    },
    {
      title: '监控点ID',
      align: 'center',
      dataIndex: 'spId',
    },
    {
      title: '监控点名称',
      align: 'center',
      dataIndex: 'spName',
    },
    {
      title: '监控点类型名称',
      align: 'center',
      dataIndex: 'spTypeName',
    },
  ];
  return (
    <Table
      className={classnames(styles['table-wrap'], styles['alarm-height'])}
      columns={columns}
      rowKey={(item, index) => {
        return index.toString(36) + index;
      }}
      {...tableProps}
      pagination={{ ...tableProps.pagination, showQuickJumper: true, showSizeChanger: true }}
    />
  );
};
export default DictionnaryTable;
